﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using DevExpress.XtraTabbedMdi;
using DevExpress.XtraBars;
using DevExpress.XtraSplashScreen;
namespace ddb_BT1
{
    public partial class frmMain : DevExpress.XtraEditors.XtraForm
    {
        public frmMain()
        {
            InitializeComponent();
        }
        public void Enable_MenuLeft()
        {
            menuLeft.Enabled = true;
        }

        public string username = "LONGTRIEU";


        private void frmMain_Shown(object sender, EventArgs e)
        {
            frmDangNhap frm = new frmDangNhap(this);
            frm.ShowDialog();
        }

        

        private void frmMain_Load(object sender, EventArgs e)
        {

        }
        public void PhanQuyen()
        {
            List<string> CHUCNANG = new List<string>();

            DataTable dt = DataProvider.getDataTable(string.Format("select * from QUANTRI where username='{0}'", username));
            if (dt.Rows.Count == 0) return;
            CHUCNANG.AddRange(dt.Rows[0][1].ToString().Split('-'));
            foreach (BarItem b in barManager1.Bars.Manager.Items)
            {
                if (CHUCNANG.IndexOf(b.Caption) > -1)
                {
                    b.Enabled = false;
                }
            }
        }

        private void navHoaDonBanHang_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            foreach (Form f in this.MdiChildren)
            {
                if (f.Name == "frmDanhSachHDBanHang") { f.Focus(); return; }
            }
            SplashScreenManager.ShowForm(typeof(WaitForm1));
            frmHoaDonBanHangFinal frm = new frmHoaDonBanHangFinal("PN00005");
            frm.MdiParent = this;
            frm.Show();
            SplashScreenManager.CloseForm();
        }

        private void barButtonItem13_ItemClick(object sender, ItemClickEventArgs e)
        {
            foreach (Form f in this.MdiChildren)
            {
                if (f.Name == "frmQuanTriNguoiDung") { f.Focus(); return; }
            }
            SplashScreenManager.ShowForm(typeof(WaitForm1));
            frmQuanTriNguoiDung frm = new frmQuanTriNguoiDung();
            frm.MdiParent = this;
            frm.Show();
            SplashScreenManager.CloseForm();
        }

        private void simpleButton1_Click(object sender, EventArgs e)
        {

        }

        private void navThan_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            foreach (Form f in this.MdiChildren)
            {
                if (f.Name == "frmQuanTriNguoiDung") { f.Focus(); return; }
            }
            SplashScreenManager.ShowForm(typeof(WaitForm1));
            frmNhapkhoNhapKhau frm = new frmNhapkhoNhapKhau();
            frm.MdiParent = this;
            frm.Show();
            SplashScreenManager.CloseForm();
        }


    }
}